<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="ie=edge,chrome=1">
    <meta name="author" content="CYW">
    <title></title>
    <style>
    body{
            margin:0 auto;
        }
    *{
        box-sizing: border-box;
    }

    .box{
        margin: 100px auto;
        width: 520px;
        height: 280px;
        /* border:1px solid red; */
        position: relative;
    }
    ul{
        margin: 0;
        padding: 0;
        list-style: none;
    }
    .img-list li{
        display: none;
        position: absolute;

    }
    li.current{
         display: block; 
    }
    .indicator{
     width:100%;
     height: 30px;
     color: white;
     position: absolute;
     bottom: 10px;
     display: flex;
     justify-content: center;
    }
    .indicator li{
      text-align: center;
      margin-left: 20px;
      width: 20px;
      height: 20px;
      line-height: 20px;
      border-radius: 50%;
     background-color: #aaa;
      cursor: pointer;
    }
    .img-click{
        display: none;
    }

    .img-click span{
        width: 30px;
        height: 60px;
        line-height: 60px;
        font-size: 20px;
        color: white;
        text-align: center;
        position: absolute;
        top: calc(50% - 20px);
        background-color: rgba(0, 0, 0,0.1);
        /* display: none; */
        cursor: pointer;

    }
    .img-click .prev{
        left: 0;
    }
    .next{
        right: 0;
    }


    
    .img-list li.current{
        display: block;
    }
    li.active{
        background-color: red;
    } 
        
    </style>
</head>
<body>
    <div class="box">
      <ul class="img-list">
            <li class="current"><a href="#"><img src="img/01.jpg" alt=""></a></li>
            <li><a href="#"><img src="img/02.jpg" alt=""></a></li>
            <li><a href="#"><img src="img/03.jpg" alt=""></a></li>
            <li><a href="#"><img src="img/04.jpg" alt=""></a></li>
            <li><a href="#"><img src="img/05.jpg" alt=""></a></li>
        </ul>

        <ul class="indicator">
            <li class="active">1</li>
            <li>2</li>
            <li>3</li>
            <li>4</li>
            <li>5</li>
        </ul>

        <div class="img-click">
            <span class="prev">&lt;</span>
            <span class="next">&gt;</span>
        </div>
    </div>

   <script src="jquery.js"></script>
</body>
</html>
<script>
 

var index = 0;

function show(){
    $('.img-list li').eq(index).fadeIn(600).siblings().fadeOut(400);
    $('.indicator li').eq(index).addClass('active').siblings().removeClass('active');
}
var timer = setInterval(nextImg,1000)
function nextImg(){
    index = index == $('.img-list li').length - 1 ?  0 : index + 1 ;
    show();
    console.log(index)
}
function prevImg(){
    index = index == 0 ? $('.img-list li').length - 1 : index - 1 ;
    show();
}

$('.indicator li').mouseover(function(){
  index = $(this).index();
    show();
});

$('.box').hover(function(){
 clearInterval(timer)

 $('.img-click').show();
 
},function(){
     $('.img-click').hide();
    timer = setInterval(nextImg,1000)
});


$('.prev').click(function(){
  prevImg()
});

$('.next').click(function(){
  nextImg()
});


</script>